package com.atguigu.yygh.msm.listener;/*
 * @author: XueYouPeng
 * @time: 2023/6/19 19:32
 */


import com.atguigu.mq.consts.MqConst;
import com.atguigu.yygh.vo.msm.MsmVo;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class MsmListener {


    @RabbitListener(
            bindings = {
                    @QueueBinding(
                            value = @Queue(name = MqConst.QUEUE_MSM_ITEM,durable = "true"), //第二个队列名称
                            exchange = @Exchange(name = MqConst.EXCHANGE_DIRECT_MSM), //交换机（默认direct类型）
                            key = MqConst.ROUTING_MSM_ITEM //队列和交换机绑定时指定的key
                    )
            }
    )
    public void aa(MsmVo msmVo){

        String phone = msmVo.getPhone();//手机号
        Object message = msmVo.getParam().get("message");//短信内容


        System.out.println("模拟短信通知的发送：" + phone +","+ message);

    }

}
